import { InitModalMethod, ParseModalMethod } from './defination';

/**
 * 设置表单属性
 * @param { Object } form 表单数据
 * @param { Object } workstep cached的ai工作流
 */
export const initModalData = (form = {}, workstep = {}) => {
	if (!form || !workstep || !workstep.do) {
		return;
	}
	form.waitTime = workstep.do.data; // 1
	form.nextStepYes = workstep.do?.after?.id;
	form.name = workstep.name;
};
InitModalMethod['silentWating'] = initModalData;

/**
 * 解析表单属性
 * @param { Object } form 表单数据
 * @param { Object } workstep cached的ai工作流
 */
export const parseModalData = (form = {}, workstep = {}) => {
	console.log(form, workstep);
	if (!form || !workstep || !workstep.do) {
		return;
	}
	workstep.do.data = form.waitTime; // 1
	workstep.do.id = form.nextStepYes;
	workstep.do.no = form.nextStepYes;
	workstep.do.after.id = form.nextStepYes;
	workstep.do.after.no = form.nextStepYes;
	workstep.name = form.name;
};
ParseModalMethod['silentWating'] = parseModalData;
// {
//     "robotProperty": {
//         "needHearing": "preorder",
//         "videoType": "preorder",
//         "audioType": "preorder"
//     },
//     "name": "",
//     "do": {
//         "data": 1,
//         "command": "wait",
//         "no": "BlankNode_58",
//         "id": "BlankNode_58",
//         "type": "yes",
//         "after": {
//             "command": "jump-to",
//             "no": "BlankNode_58",
//             "id": "BlankNode_58",
//             "type": "yes"
//         }
//     },
//     "id": "silentWating_57",
//     "no": "silentWating_57",
//     "type": "silentWating",
//     "completed": true,
//     "hasStartNode": false
// }
